package cn.kxm.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.kxm.pojo.Part;
import cn.kxm.pojo.PartType;
import cn.kxm.service.PartService;
import cn.kxm.service.PartTypeService;

@Controller
@RequestMapping("/part")
public class PartController{

	@Autowired
	private PartService partService;
	@Autowired
	private PartTypeService partTypeService;
	@RequestMapping("getPartList")
	@ResponseBody
	public Object getPartList(Integer rows,Integer page,Part part){
		List<Map<String, Object>>list=partService.getPartListt(part, page, rows);
		Map<String, Object>map=new HashMap<String, Object>();
		map.put("rows", list);
		map.put("total", partService.getPartCount(part));
		return JSON.toJSON(map);
	}
	
	@RequestMapping("getAllpartType")
	@ResponseBody
	public Object getAllpartType(){
		List<PartType>list=partTypeService.getAllPartType();
		return JSON.toJSON(list);
	}
	@RequestMapping("getByCode")
	@ResponseBody
	public Object getByCode(String code){
		List<Map<String, Object>>list=partService.getByCode(code);
		return JSON.toJSON(list);
	}
	@RequestMapping("getPart_Ib")
	@ResponseBody
	public Object getPart_Ib(String row){
		
		return "";
	}
}
